(ns
  com.marzhillstudios.molehill.test-template
  (:use [clojure.test]
     [com.marzhillstudios.molehill.template]
     [com.marzhillstudios.molehill.file]))

(hill-page :foo-tmpl foo-tmpl-state
           (str (:title (first (:entries foo-tmpl-state)))
                "foo templ"))

(deftest test-template
         (is (fn? (:foo-tmpl *template-map*)))
         (is (= (call-template :foo-tmpl
                               {}
                               (new-hill-file "bar "))
                "bar foo templ"))
         (is (thrown? IllegalArgumentException
                      (call-template :bar-tmpl {}
                                     (new-hill-file "bar ")))))

(deftest test-mk-template-state
         (is (thrown? IllegalArgumentException (mk-template-state {} "foo")))
         (is (thrown? IllegalArgumentException (mk-template-state {} ["foo"])))
         (is (mk-template-state {} (new-hill-file "foo")))
         (is (mk-template-state {} [(new-hill-file "foo")
                                 (new-hill-file "bar")])))

(deftest test-default-templates-exist
         (is (fn? (get *template-map* :sample-index-tmpl)))
         (is (fn? (get *template-map* :sample-feed-tmpl)))
         (is (fn? (get *template-map* :sample-tag-tmpl)))
         (is (fn? (get *template-map* :sample-tag-landing-tmpl)))
         (is (fn? (get *template-map* :sample-entry-tmpl))))
